//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;

namespace OpenLS.Spreadsheet.Internals
{
    public class RowGroup : ChildGroup
    {
        public static RowGroup CreateColumnGroupWithNext(Group parent, Row first, Row next)
        {
            return new RowGroup(parent, first, (Row) next.GetPrevious());
        }
        public static RowGroup CreateColumnGroupWithLast(Group parent, Row first, Row last)
        {
            return new RowGroup(parent, first, last);
        }
        private RowGroup(Group parent, Row first, Row last) : base(parent, first, last) { }

        protected override void NotifyTotalChanged()
        {
            NotifyPropertyChanged("TotalHeight");
        }

        internal override IEnumerable<Dimension> GetDimensions(bool includeNext)
        {
            for (int i = First.Index; i <= Last.Index; i++)
            {
                yield return First.Worksheet.Rows[i];
            }
            if (includeNext)
                yield return Next;

        }
        public Row Next { get { return Last.Worksheet.Rows[Last.Index + 1]; } }

        public double TotalHeight { get { return Next.Offset - First.Offset + ((Row)Next).ActualHeight; } }
        protected override Dimension GetDimension(int i)
        {
            return First.Worksheet.Rows[i];
        }


    }
}
